<?php

Loader::using("ext::libs::inscripcionesGenericas::QuestionBasedUIControlFilter");
Loader::using("ext::libs::inscripcionesGenericas::dependencies::*");

class DependencyUIControlFilter extends QuestionBasedUIControlFilter {

    public function &filterControl(UIControl &$newInstance) {
        $params = $this->getDecodedParams();
        if (isset($params->dependence)) {
            $dependency = $params->dependence;

            $independentId = $dependency->Id;
            $manager = $dependency->Manager;
            $dependentId = $newInstance->getId();

            $dependencyManager = &ConstraintFactory::instance()->getConstraint($manager . "Dependency");
            $dependencyManager->addDependency(new Dependency($dependentId, $independentId));
        }

        return $newInstance;
    }

}
?>